package com.powernode.rules.controller;

import com.powernode.common.result.Result;
import com.powernode.model.form.rules.ProfitsharingRuleRequestForm;
import com.powernode.model.vo.rules.ProfitsharingRuleResponseVo;
import com.powernode.rules.service.ProfitsharingRuleService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 分账规则控制器
 * 处理订单分账相关的HTTP请求，提供分账计算等功能接口
 */
@Slf4j
@RestController
@RequestMapping("/rules/profitsharing")
@SuppressWarnings({"unchecked", "rawtypes"})
public class ProfitsharingRuleController {
    @Resource
    private ProfitsharingRuleService profitsharingRuleService;// 分账规则服务，用于执行业务逻辑

    /**
     * 计算系统分账费用接口
     * 根据请求参数计算符合条件的订单分账金额
     *
     * @param profitsharingRuleRequestForm 请求体参数，包含计算分账所需的信息（如订单金额等）
     * @return 响应结果，包含计算得到的分账金额信息
     */
    @Operation(summary = "计算系统分账费用")
    @PostMapping("/calculateOrderProfitsharingFee")
    public Result<ProfitsharingRuleResponseVo> calculateOrderProfitsharingFee(@RequestBody ProfitsharingRuleRequestForm profitsharingRuleRequestForm) {
        return Result.ok(profitsharingRuleService.calculateOrderProfitsharingFee(profitsharingRuleRequestForm));
    }
}

